package com.gugee.ins.common.dal.mapper.brand;

import com.gugee.common.mapper.GugeeMapper;
import com.gugee.ins.common.dto.InsBrandDto;
import com.gugee.ins.common.model.mysql.brand.InsBrand;
import com.gugee.ins.common.model.mysql.brand.InsRelBrandBlogger;
import com.gugee.ins.data.common.msg.InsBrandMessage;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * InsBrandMapper
 * @author huangxin
 */
public interface InsBrandMapper extends GugeeMapper<InsBrand> {
    /**
     * 获取最大id
     * @return
     */
    @Select("select max(id) from common_brand where checked != -1")
    int getMaxId();

    /**
     * 获取定时分页信息
     * @param startId
     * @param endId
     * @param limitTime
     * @return
     */
    @Select("select id as bid from common_brand " +
            " where id between #{startId} and #{endId} and checked != -1 " +
            " AND last_analysis_category_time < #{limitTime} ")
    List<InsBrandMessage> findInsAnalysisBrandCategoryMessageByPages(int startId, int endId, long limitTime);

    /**
     * 获取打点定时分页信息
     * @param startId
     * @param endId
     * @return
     */
    @Select("select t1.id bid,t2.uid from common_brand t1 " +
            " inner join ins_rel_brand_blogger t2 " +
            " on t1.id = t2.bid " +
            " where t1.id between #{startId} and #{endId} and checked != -1 " +
            " order by t1.id ")
    List<InsRelBrandBlogger> findInsMarkBrandMessageByPages(int startId, int endId);

    /**
     * 获取打点定时分页信息
     * @param startId
     * @param endId
     * @return
     */
    @Select("select distinct t1.id,t1.category_name from common_brand t1 " +
            " inner join ins_rel_brand_blogger t2 " +
            " on t1.id = t2.bid " +
            " where t1.id between #{startId} and #{endId} and checked != -1 ")
    List<InsBrandDto> findInsBrandDtoByPages(int startId, int endId);
}